#include <iostream>
using namespace std;
const int e[15]={1,2,4,8,16,32,64,128,256,512,1024,2048,4096,8192};
int main()
{
    int work,time,prise[2][15];
    cin>>work>>time;
    int i,j,max_get=0,now_get,time_l,temp;
    for(i=0;i<work;i++)
    {
        cin>>prise[0][i]>>prise[1][i];
    }
    for(i=0;i<e[work];i++)
    {
        now_get=0;
        time_l=time;
        for(j=0;j<work;j++)
        {
            temp=i&e[j];
            if(temp)
            {
                time_l-=prise[0][j];
                now_get+=prise[1][j];
            }   
        }
        if(time_l<0)
        {
            continue;    
        }
        if(now_get>max_get)
        {
            max_get=now_get;
        }
    }
    cout<<max_get;
    return 0;
}

